package com.cy.listener;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.ImageIcon;
import javax.swing.JLabel;

import com.cy.controller.MusicController;

/**
 * 开关背景音乐监听
 * @author CY
 *
 */
public class BackgroundMusicListener extends MouseAdapter {

	@Override
	public void mouseClicked(MouseEvent e) {
		//开或关声音
		MusicController.playSelect();
		JLabel jl = (JLabel) e.getComponent();
		//开啦
		if(MusicController.switchoverBackgroundMusic()) {
			jl.setIcon(new ImageIcon("image/turnon.png"));
		}else {//关啦
			jl.setIcon(new ImageIcon("image/turnoff.png"));
		}
	}

}
